package com.gagakuai.statement;

import com.gagakuai.executor.resultset.ResultSetHandler;
import com.gagakuai.mapping.BoundSql;
import com.gagakuai.session.ResultHandler;

import java.sql.SQLException;
import java.sql.Statement;

/*
 * @program: common-starters
 * @description: 简单查询器
 * @author: houhong
 * @create: 2023-07-01 21:28
 */
public class SimpleStatementHandler extends BaseStatementHandler {


    protected final ResultSetHandler resultSetHandler;

    protected BoundSql boundSql;

    @Override
    public <E> E query(Statement statement, ResultHandler resultHandler) throws SQLException {
        //sql语句
        String sql = boundSql.getSql();
        statement.execute(sql);
        return (E) resultSetHandler.handleResultSets(statement);
    }
}